package com.hotel.tv.services.impl;

import com.autumn.mybatis.wrapper.EntityQueryWrapper;
import com.autumn.security.constants.UserStatusConstants;
import com.autumn.zero.authorization.services.UserRoleDefinition;
import com.hotel.tv.constants.HotelUserTypeConstant;
import com.hotel.tv.constants.SysResourcesTypeConstants;
import com.hotel.tv.entities.auth.HotelRole;
import com.hotel.tv.entities.auth.HotelUser;

import java.util.Date;

/**
 * 超级管理员定义
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-04-19 01:12
 **/
public class HotelAdministratorDefinition implements UserRoleDefinition<HotelUser, HotelRole> {

    @Override
    public HotelUser createUser() {
        HotelUser user = new HotelUser();
        user.setUserName("admin");
        user.setRealName("系统管理员");
        user.setNickName("");
        user.setPassword("admin");
        user.setSex("");
        user.setGmtCreate(new Date());
        user.setUserType(HotelUserTypeConstant.HOTEL_ADMIN);
        user.setOrganizeId(null);
        user.setStatus(UserStatusConstants.NORMAL);
        return user;
    }

    @Override
    public HotelRole createRole() {
        HotelRole role = new HotelRole();
        role.setName("administrators");
        role.setIsSysRole(true);
        role.setSortId(1);
        role.setGmtCreate(new Date());
        role.setSummary("具有系统所有权限");
        role.setUserType(HotelUserTypeConstant.HOTEL_ADMIN);
        role.setOrganizeId(null);
        return role;
    }

    @Override
    public void setRoleRelationCondition(EntityQueryWrapper<HotelRole> wrapper) {
        wrapper.lambda().where().eq(HotelRole::getUserType, HotelUserTypeConstant.HOTEL_ADMIN);
    }

    @Override
    public int getModuleResourcesType() {
        return SysResourcesTypeConstants.ADMIN_RESOURCES;
    }
}
